/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1638326141101_694';

  config.cluster = {
    listen: {
      port: 7075,
    },
  };

  // add your middleware config here
  config.middleware = [];

  config.bus = {
    debug: true, // Debug 模式下会打印更多日志信息
    concurrency: 1, // Bull 中队列处理的并发数：https://github.com/OptimalBits/bull/blob/develop/REFERENCE.md#queueprocess
    listener: {
      ignore: null, // 忽略目录中的某些文件，https://eggjs.org/zh-cn/advanced/loader.html#ignore-string
      baseDir: 'listener',
      options: { // Bull Job 配置： https://github.com/OptimalBits/bull/blob/develop/REFERENCE.md#queueadd
        attempts: 5,
        backoff: {
          delay: 3000,
          type: 'fixed',
        },
      },
    },
    job: {
      // 与 listener 一致，唯一不同的就是 默认 baseDir 的值为 `job`
    },
    bull: { // Bull 队列配置：https://github.com/OptimalBits/bull/blob/develop/REFERENCE.md#queue
      redis: {
        host: '192.168.2.6',
        port: 6379,
        db: 2,
      },
    },
    queue: {
      default: 'default', // 默认队列名称
      prefix: 'bus', // 队列前缀
    },
    queues: { // 针对不同队列单独配置
      // 比如针对默认队列更改 redis 端口
      // default: {
      //   redis: {
      //     host: '192.168.2.6',
      //     port: 6379,
      //   },
      // },
    },
  };

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  return {
    ...config,
    ...userConfig,
  };
};
